package demo1;

/**
 * @Auther: 杨通通
 * @Date: 2024/10/22 00:19
 * @Description:
 */
public class CountThread implements Runnable{
    private int i = 0;
    @Override
    public void run() {
        while (true){
            synchronized (this){
                notify();
                if(i<100){
                    i++;
                    System.out.println(Thread.currentThread().getName()+"打印："+i);
                }else{
                    break;
                }
                try {
                    wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }


        }
    }
}